//
//  GYCartConfirmAddressView.m
//  GYDemo
//
//  Created by mac on 2018/6/26.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "GYCartConfirmAddressView.h"
#import "Head.h"

@interface GYCartConfirmAddressView()
@property (nonatomic,strong) UIImageView *bgIV;
@property (nonatomic,strong) UILabel *titleLB;
@property (nonatomic,strong) UILabel *detailTitleLB;
@property (nonatomic,strong) UILabel *detailLB;
@property (nonatomic,strong) UILabel *newAddressLB;
@property (nonatomic,strong) UIImageView *signIV;
@end

@implementation GYCartConfirmAddressView
#pragma mark - getter and setter
-(UIImageView *)bgIV
{
    if (!_bgIV) {
        _bgIV = [UIImageView new];
        _bgIV.image = [UIImage imageNamed:@"dizhi"];
        _bgIV.frame = WFCGRectMake(0, 1, 4, 80);
    }
    return _bgIV;
}

-(UILabel *)titleLB
{
    if (!_titleLB) {
        _titleLB = [UILabel new];
        _titleLB.frame = WFCGRectMake(19, 10, 375 - 18, 20);
        _titleLB.font = SYSTEMFONT(14);
        _titleLB.textColor = Main_Color_Black;
    }
    return _titleLB;
}

-(UILabel *)detailTitleLB
{
    if (!_detailTitleLB) {
        _detailTitleLB = [UILabel new];
        _detailTitleLB.frame = WFCGRectMake(19, 37, 65, 16);
        _detailTitleLB.font = SYSTEMFONT(12);
        _detailTitleLB.textColor = Main_Color_Black;
        _detailTitleLB.text = @"收货地址：";
        _detailTitleLB.hidden=YES;
    }
    return _detailTitleLB;
}

-(UILabel *)detailLB
{
    if (!_detailLB) {
        _detailLB = [UILabel new];
        _detailLB.frame = WFCGRectMake(75, 37, 375 - 75 * 2, 33);
        _detailLB.font = SYSTEMFONT(12);
        _detailLB.numberOfLines = 0;
        _detailLB.textColor = Main_Color_Black;
    }
    return _detailLB;
}

-(UILabel *)newAddressLB
{
    if (!_newAddressLB) {
        _newAddressLB = [UILabel new];
        _newAddressLB.frame = WFCGRectMake(19, 29, 200, 20);
        _newAddressLB.font = SYSTEMFONT(14);
        _newAddressLB.textColor = Main_Color_Black;
        _newAddressLB.text = @"添加收货地址";
    }
    return _newAddressLB;
}

-(UIImageView *)signIV
{
    if (!_signIV) {
        _signIV = [UIImageView new];
        _signIV.frame = WFCGRectMake(354, 32, 8, 14);
        _signIV.image = [UIImage imageNamed:@"Shape"];
    }
    return _signIV;
}
-(void)setModel:(GYMineShopAddressModel *)model
{
    if (model) {
        _model = model;
        _titleLB.hidden = NO;
        _detailLB.hidden = NO;
        _detailTitleLB.hidden = NO;
        _newAddressLB.hidden = YES;
        
        NSString *name = _model.name;
        NSString *mobile = _model.phone;
        NSString *titles = [NSString stringWithFormat:@"收货人：%@  %@",name,mobile];
        NSString *province = _model.province;

        NSString *address = _model.address;
        NSString *addresses = [NSString stringWithFormat:@"%@%@",province,address];
        _titleLB.text = titles;
        _detailLB.text = addresses;
        CGFloat height = [WFFunctions WFStrGetSize:addresses width:_detailLB.width font:_detailLB.font].height;
        _detailLB.height = height > WFCGFloatY(33) ? WFCGFloatY(33) : height;
    }else{
        _titleLB.hidden = YES;
        _detailLB.hidden = YES;
        _detailTitleLB.hidden = YES;
        _newAddressLB.hidden = NO;
    }
}
#pragma mark - method
#pragma mark - life
-(instancetype)init
{
    if (self = [super init]) {
        self.backgroundColor = Main_Color_White;
        self.width = ScreenWidth;
        self.height = WFCGFloatY(82);
        [self addSubview:self.bgIV];
        [self addSubview:self.titleLB];
        [self addSubview:self.detailTitleLB];
        [self addSubview:self.detailLB];
        [self addSubview:self.newAddressLB];
        [self addSubview:self.signIV];
        UIView *sep = [UIView new];
        sep.height = 1;
        sep.width = self.width;
        sep.y = self.height - 1;
        sep.backgroundColor = Main_Color_BG;
        [self addSubview:sep];
    }
    return self;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
